//
//  NetWorkTiils+Status.swift
//  MXWeiBo
//
//  Created by Apple on 16/2/27.
//  Copyright © 2016年 Applea. All rights reserved.
//

import Foundation

//    MARK:  --加载微博数据
extension NetworkTools {

    func loadStatus(mxsice_id since_id:Int64 = 0,max_id: Int64 = 0, finished: ([String: AnyObject]?)->()) {
    
//    1.判断 token 是否存在，如果不存在，用户没有登录
//        TODO: -处理 token 过期
        guard let accessToken = UserAccount.sharedUserAccount.access_token else {
         return
        
        }
        let urlString = "https://api.weibo.com/2/statuses/home_timeline.json"
        var parame :[String : AnyObject] = ["access_token": accessToken]
        
//        判断下拉 id 
        if since_id > 0 {
          parame["since_id"] = NSNumber(longLong: since_id)
        }
        if max_id > 0 {
            parame["max_id"] = NSNumber(longLong: max_id - 1 )
        }
        request(.GET, URLString: urlString, parameters: parame, finished: finished)
    }
}